//
//  LoginSetPasswordV.m
//  ZITHER
//
//  Created by weixin on 2019/1/17.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "LoginSetPasswordV.h"
#import "MeRegisterRegisterVC.h"

@interface LoginSetPasswordV()
@property (nonatomic,strong)BaseLab * succeedTipeLab;

@property (nonatomic,strong)BaseImageV * userPic;
@property (nonatomic,strong)BaseLab * userName;

@property (nonatomic,strong)BaseBtn * donebtn;
@property (nonatomic,strong)BaseBtn * cancelbtn;


@end


@implementation LoginSetPasswordV

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
     
        self.backgroundColor = [UIColor whiteColor];
        
        [self setCornerRadiusWithRadius:10 isMasks:YES];

        [self setUI];
        
        [self setMasonry];
        
        [self setData];
        
    }
    return self;
}
-(void)setData{
    self.userName.text = kUSER_INFO_MANAGER.nickName;
    [self.userPic sd_setImage:kUSER_INFO_MANAGER.avatar];
}
-(void)setUI{
    
    [self addSubview:self.userName];
    [self addSubview:self.userPic];
    [self addSubview:self.donebtn];
    [self addSubview:self.succeedTipeLab];
    [self addSubview:self.cancelbtn];

}

-(void)setMasonry{
    
    [self.userPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(60);
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.height.width.mas_equalTo(120);
    }];
    
    [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.userPic.mas_bottom).offset(15);
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.height.mas_equalTo(20);
    }];
    
    [self.succeedTipeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.userName.mas_bottom).offset(50);
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.height.mas_equalTo(17);
    }];
    
    [self.donebtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(0);
        make.bottom.equalTo(self).offset(0);
        make.height.mas_equalTo(55);
        make.width.mas_equalTo((kScreenW-60)/2.0);
    }];
    [self.cancelbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(0);
        make.bottom.equalTo(self).offset(0);
        make.height.mas_equalTo(55);
        make.width.mas_equalTo((kScreenW-60)/2.0);
    }];
    
    for (int i = 0 ; i<2; i++) {
        BaseView *view = [[BaseView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        view.backgroundColor = HexColor(0xeeeeee);
        [self addSubview:view];
        
        if (i == 0 ) {
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self).offset(0);
                make.bottom.equalTo(self).offset(-55);
                make.height.mas_equalTo(1);
                make.width.mas_equalTo((kScreenW-60));
            }];
        }else{
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.equalTo(self.mas_centerX).offset(0);
                make.centerY.equalTo(self.cancelbtn.mas_centerY).offset(0);
                make.height.mas_equalTo(30);
                make.width.mas_equalTo(1);
            }];
            
        }
    }
}

-(BaseLab *)succeedTipeLab{
    if (!_succeedTipeLab) {
        _succeedTipeLab = [[BaseLab alloc]initializeFrame:CGRectMake(0, 0, 0, 0) text:@"建议设置固定登录密码,无需再每次请求验证码。" font:10 textColor:HexColor(0x999999) isBold:NO numberOfLines:1];
        _succeedTipeLab.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
        
    }
    return _succeedTipeLab;
}

- (BaseImageV *)userPic{
    if (!_userPic) {
        _userPic = [[BaseImageV alloc]initializeFrame:CGRectMake(0, 0, 0, 0) contentMode:2];
        _userPic.image = [UIImage imageNamed:@"注册成功_默认头像"];
        _userPic.backgroundColor = [UIColor colorWithHex:@"f5f5f5"];
        [_userPic setCornerRadiusWithRadius:60 isMasks:YES];
 
    }
    return _userPic;
}

-(BaseLab *)userName{
    if (!_userName) {
        _userName = [[BaseLab alloc]initializeFrame:CGRectMake(0, 0, 0, 0) text:@"设置用户名称" font:10 textColor:HexColor(0x333333) isBold:NO numberOfLines:1];
        _userName.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:13];

    }
    return _userName;
}

- (BaseBtn *)donebtn{
    if (!_donebtn) {
        _donebtn = [[BaseBtn alloc]initializeFrame:CGRectMake(0, 0, 0, 0) NormalText:@"设置" NormalTextColor:baseColorTheme SeleText:nil SeleTextColor:nil font:14 isBold:NO];
        _donebtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
        /** 按钮点击案例 */
        @weakify(self);
        [[_donebtn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            if (self.blockHide) {
                self.blockHide(1);
            }

        }];
    }return _donebtn;
}
- (BaseBtn *)cancelbtn{
    if (!_cancelbtn) {
        _cancelbtn = [[BaseBtn alloc]initializeFrame:CGRectMake(0, 0, 0, 0) NormalText:@"不用" NormalTextColor:[UIColor colorWithHex:@"999999"] SeleText:nil SeleTextColor:nil font:14 isBold:NO];
        _cancelbtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
        /** 按钮点击案例 */
        @weakify(self);
        [[_cancelbtn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            if (self.blockHide) {
                self.blockHide(0);
            }
        }];
    }return _cancelbtn;
}

@end
